$(document).ready(function(){
	$(".btn_close").on("click", function(event) {
		window.close();
	});
	
	$(".btn_save").on("click", function(event) {
		
		url = "insertRoleAdd.jsp";
		serviceName = "ROLE_ADD";
		param = {
				system_name : $("#system_name").val(),
				lock_group_name : $("#lock_group_name").val(),
				target_list : $("#target_list").val(),
				lock_group_ex : $("#lock_group_ex").val()				
		};
		
		callAjax(url,param, serviceName);
	});
	
	/* GROUP 중복체크 */
	$(".btn_overlapchk").on("click", function(event) {
		var url = "checkRole.jsp";
		var serviceName = "ROLE_CHECKGROUP";
		var param = {
				lock_group_name : $("#lock_group_name").val()
		};
		callAjax(url,param, serviceName);
	});
	
	/* info + 클릭시 */
	$("#system_add").on("click", function(event) {
		var url = "insertSystem.jsp";
		var serviceName = "SYSTEM_ADD";
		var param = {
				target_list : $("#target_list").val(),
				system_type : $("#system_type option:selected").val()
		};
		callAjax(url,param, serviceName);
	});
	/* info - 클릭시 */
	$("#system_del").on("click", function(event) {
		var url = "deleteSystem.jsp";
		var serviceName = "SYSTEM_DEL";
		var param = {
				target_list : $("#target_list").val(),
				system_type : $("#system_type option:selected").val()
		};
		callAjax(url,param, serviceName);
	});
	
});

/* callAjax successAjax */
function successAjax(data, serviceName){
	if(serviceName == "ROLE_ADD"){
		alert(data.result);
	}else if(serviceName == "ROLE_CHECKGROUP"){
		alert(data.result);
	}else if(serviceName == "SYSTEM_ADD"){
		alert(data.result);
	}else if(serviceName == "SYSTEM_DEL"){
		alert(data.result);
	}
}